<div id="error">
   <?php
    echo @$this->session->flashdata('error_title');
    ?>
</div>
<script language="javascript">
    // apply filters
    var applyFilter = function()
    {

    }
    jQuery(document).ready(function(){
        jQuery("#list").jqGrid({
            url: '<?php echo site_url() ?>/trancrearcompania/datahistorico',
            mtype: 'POST',
            datatype: 'json',
            colNames:['ID','Referencia','Servicio','C. Servicio','Provincia','Fecha Inicio','Fecha Fin','Usuario'],
            colModel :[
                       {name:'IdCompania', index:'IdCompania', width:10,hidden:true},
                       {name:'NombreCompania', index:'NombreCompania', width:40},
                       {name:'IdServicio', index:'IdServicio', width:40},
                       {name:'cServicios', index:'clasificacion_servicios', width:40},
                       {name:'IdProvincia', index:'IdProvincia', width:40},
                       {name:'FechaUsrCompania', index:'FechaUsrCompania', width:40},
                       {name:'FechaHistorico', index:'FechaHistorico', width:40},
                       {name:'IdUsuarioHistorico', index:'IdUsuarioHistorico', width:40},
                       ],
            pager: jQuery('#pager'),
            hiddengrid: true,
            sortname: 'IdCompania',
            rowNum:100,
            rowList:[100,130,170, 200, 230],
            sortorder: "DESC",
            height: '100%',
            width: '650',
            imgpath: _base_url + 'public/css/jqgrid/flex/images',
            viewrecords: true,
            multiselect: false,
            onSelectRow: function(ids)
            {
            	if(ids != null)
            	{
            		var rec = jQuery("#list").getRowData(ids);
            		lol=ids;
            	}
            },
            adjacents: 4,
            jsonReader: { repeatitems : false, IdCompania: "0" }
        }).navGrid('#pager',{add:false,del:false,edit:false,search:false,position:"left"})

         .navButtonAdd('#pager',{caption:"", buttonimg: _base_url + "public/css/jqgrid/flex/images/text_columns.png", onClickButton:function(){ jQuery("#list").setColumns();} })

         .navButtonAdd('#pager',{caption:"Detalles", buttonimg: _base_url + "public/images/edit.png", onClickButton:function()
         {
           var id = jQuery('#list').getGridParam('selarrrow');
           var id=lol;
           if (id.length > 0)
           {
              
                  var ret = jQuery("#list").getRowData(id);
                  window.location = _site_url + '/trancrearcompania/detalleHistorico/' + ret.IdCompania;
             

            }else{
                  jAlert('Debe seleccionar al menos una compania');
                 }
        return false;
        } })

        $('#apply_filter').bind('click', applyFilter);
    });
</script>
<div class="table_container">
<table>
    <tr>
    	<td><div id="titulo">Historico Servicios</div><?php $this->load->view('etapas_filters'); ?></td>
    </tr>
    <tr>
        <td>
            <table id="list" class="scroll"></table>
            <div id="pager" class="scroll" style="text-align:center;"></div>
        </td>
	</tr>
 </table>
</div>